package com.wjf.birdfish.commons;

import java.io.IOException;
import java.util.Date;
import java.util.Map;
import java.util.Timer;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;


/**
 * Created on 2006-12-18
 * <p>
 * Title: 判断用户是否登录的过滤器
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright TYDIC (c) 2006
 * </p>
 * <p>
 * Company: tydic.com
 * </p>
 * 
 * @author <a href="mailto:tongys@tydic.com">童永胜</a>
 * @version 1.0
 */
public class CheckLoginFilter implements Filter {

	private Logger log = Logger.getLogger(getClass().getName());

	public FilterConfig config = null;
	private Timer timer = new Timer(true);

	public void init(FilterConfig config) throws ServletException {
		this.config = config;
		log.info("Initializing filter 'encodingFilter'");
		
		
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {

	}

	public void destroy() {
		config = null;
		timer.cancel();
	}

	/**
	 * 检查当前访问url是否是范围以外的
	 * 
	 * @param request
	 * @return 是排除以外url返回true，否则返回false
	 */
	private boolean isExcludeUrl(HttpServletRequest request) {
		boolean result = false;

		String path = request.getServletPath();
		if (path.equalsIgnoreCase("/login.jsp")) {
			result = true;
		} else if (path.indexOf("/login.do") >= 0) {
			result = true;
		} else {
			result = false;
		}

		return result;
	}

}